package br.com.rsrpp.domain.model;

import java.io.Serializable;
import java.util.List;
import java.util.Set;
import java.util.HashSet;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

@Entity
@Table(name="usuario")
public class Usuario implements Serializable {

	private int id_usuario;
	private String nome;
	private String email;
	private Endereco endereco;
	private List<UP> listUP;
	//private Set<PS> ps = new HashSet<PS>(0);
	
	public Usuario() {
	}
		
	public Usuario(String nome, String email, Endereco endereco) {
		super();
		this.nome = nome;
		this.email = email;
		this.endereco = endereco;
	}

	@Id 
	@GeneratedValue  
	@Column(name="id_usuario")
	public int getId_usuario() {
		return id_usuario;
	}
	public void setId_usuario(int id_usuario) {
		this.id_usuario = id_usuario;
	}
	
	@Column(name="nome", nullable=false, length=100, unique=true) 
	public String getNome() {
		return nome;
	}
	public void setNome(String nome) {
		this.nome = nome;
	}
	
	@Column(name="email", nullable=false, length=100)
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	
	@OneToOne(cascade = CascadeType.ALL)
	@JoinColumn(name="id_endereco")
	public Endereco getEndereco() {
		return endereco;
	}
	public void setEndereco(Endereco endereco) {
		this.endereco = endereco;
	}

	@OneToMany(mappedBy = "usuario", cascade = CascadeType.ALL)
	public List<UP> getListUP() {
		return listUP;
	}
	public void setListUP(List<UP> listUP) {
		this.listUP = listUP;
	}
	
/*	@ManyToMany(cascade = CascadeType.ALL)
	@JoinTable(name = "usuario_ps", joinColumns = { @JoinColumn(name = "id_usuario")} , inverseJoinColumns = {@JoinColumn(name = "id_ps")})
	public Set<PS> getPs() {
		return ps;
	}
	public void setPs(Set<PS> ps) {
		this.ps = ps;
	}*/
}
